import { getInstance } from "/@/utils/request";

const state = {
    type: [],
    status: [
        {
            status: 0,
            name: "空闲"
        },
        {
            status: 1,
            name: "已入住"
        },
        {
            status: 2,
            name: "整理中"
        }
    ]
}

const mutations = {
    setType(state, type){
        state.type = type;
    },
    addType(state, type){
        state.type.push(type)
    }
}

const actions = {
    async setType({commit}){
        let data = await getInstance().get("/type/list");
        if(data.code === 0){
            commit("setType", data.data.content)
        }else{
            commit("setType", [])
        }
    },
    addType({commit}, type){
        commit("addType", type)
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}